package com.nidu.demo.company.convertor;

import com.nidu.demo.base.BaseConvertor;
import com.nidu.demo.company.dto.CompanyCO;
import com.nidu.demo.company.mapper.dataobject.CompanyDO;
import com.nidu.demo.company.model.Company;
import com.nidu.demo.convertor.MapStructConfig;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(config = MapStructConfig.class)
public interface CompanyConvertor extends BaseConvertor<CompanyDO, Company, CompanyCO> {
    
    @Override
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "createBy", ignore = true)
    @Mapping(target = "updateBy", ignore = true)
    @Mapping(source = "companyName", target = "name")
    @Mapping(source = "companyAddress", target = "address")
    @Mapping(source = "companyPhoneNumber", target = "phoneNumber")
    CompanyDO toDataObject(Company company);

    @Override
    @Mapping(source = "name", target = "companyName")
    @Mapping(source = "address", target = "companyAddress")
    @Mapping(source = "phoneNumber", target = "companyPhoneNumber")
    Company toDomainObject(CompanyDO dataObject);
}